Conversation
… new device appears Replace bare [0] indexing on the lun diff list with an explicit assertion that the new device set is non-empty, providing a clear error message about max_data_disk_count mismatch instead of an opaque IndexError.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the Storage test suite hot-add helper by replacing an unsafe empty-list index with an assertion and a safer retrieval approach when no new Linux block device is detected after attaching a disk.
Changes:
- Add an explicit non-empty assertion for newly discovered device keys when comparing
Disk.get_luns()before/after hot-add. - Replace direct
[0]indexing withnext(iter(...))after validating the set difference is non-empty. - Improve failure diagnostics by including LUN and before/after device mappings in the assertion message.
❌ AI Test Selection — FAILED74 test case(s) selected (view run) Marketplace image: canonical 0001-com-ubuntu-server-jammy 22_04-lts-gen2 latest
Test case details
|
LiliDeng
approved these changes
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix an
IndexError: list index out of rangecrash in_hot_add_disk_serial()when a hot-added data disk does not appear as a new Linux block device after attachment.Root Cause
The method computed the set difference of device keys before vs. after hot-add, then immediately indexed
[0]on the resulting list without checking whether it was empty. If the disk was not yet visible (timing race) or failed to appear, the empty-list access raisedIndexError.Fix
[0]indexing with an explicitassert_that(...).is_not_empty()assertion that produces a clear diagnostic message including the expected LUN number.next(iter(...))to retrieve the first element safely after the assertion guarantees non-emptiness.Validation
Tested on 3 distro families with
verify_hot_add_disk_serial_premium_ssd:All lint checks pass (black, flake8, mypy).